Skip to content

Fix auto refresh token logic to ensure timely token renewal#442

Merged
NipuniBhagya merged 5 commits intoasgardeo:mainfrom
NipuniBhagya:token-fix
Apr 8, 2026
Merged

Fix auto refresh token logic to ensure timely token renewal#442
NipuniBhagya merged 5 commits intoasgardeo:mainfrom
NipuniBhagya:token-fix

Conversation

@NipuniBhagya
Copy link
Copy Markdown
Contributor

@NipuniBhagya NipuniBhagya commented Apr 7, 2026

Purpose

This pull request fixes an error in the auto refresh token logic for the @asgardeo/browser package. The update ensures that access tokens are refreshed at the correct time, preventing premature or missed refreshes.

Improvements to token refresh logic:

  • Corrected the calculation for the token refresh timer in spa-helper.ts to use the token's absolute expiry time and a 10-second buffer, ensuring the refresh happens just before expiration. The logic now checks for the presence of created_at and expires_in before proceeding, and immediately refreshes the token if it's already expired or about to expire.

Changelog update:

  • Added a changeset entry documenting the patch fix for the auto refresh token logic error in @asgardeo/browser.

Related Issues

Checklist

  • Followed the CONTRIBUTING guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Add links if there are any)
  • Unit tests provided. (Add links if there are any)

Security checks


if (isAlreadySignedIn) {
await updateSession();
await asgardeo.startAutoRefreshToken();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asgardeo-github-bot
Copy link
Copy Markdown

🦋 Changeset detected

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

@NipuniBhagya NipuniBhagya merged commit 359743a into asgardeo:main Apr 8, 2026
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants